<template>
  <div>
    <van-nav-bar
      title="房屋管理"
      left-arrow
      @click-left="onClickLeft"
    />

    <van-card
      v-for="(item,index) in rentList"
      :key="index"
      :price="item.price+'元/月'"
      :desc="item.desc"
      :title="item.title"
      :thumb="'http://liufusong.top:8080'+ item.houseImg"
      @click="onclick(item)"
    >
      <template #tags>
        <van-tag plain type="danger">近地铁</van-tag>
      </template>
    </van-card>
  </div>
</template>

<script>
import { getrent } from '@/api/user.js'
import bus from '@/bus/bus.js'
export default {
  data() {
    return {
      rentList: []
    }
  },
  beforeDestroy() {
    bus.$emit('housesid', this.id)
  },
  created() {
    this.getrent()
  },

  methods: {
    onClickLeft() {
      this.$router.back()
    },
    async getrent() {
      const res = await getrent()
      console.log(res.data.body)
      this.rentList = res.data.body
    },
    onclick(val) {
      this.$router.push('/detail/' + val.houseCode)
      this.id = val.houseCode
      // console.log(val.houseCode)
    }
  }
}
</script>

<style scoped lang='less'>
.van-nav-bar{
  background-color: green;
}
/deep/.van-nav-bar__title{
  color: #fff;
}
/deep/.van-nav-bar__arrow{
  color: #fff !important;
}
  .van-card__price{
    font-size: 0;
  }
  //  #text{
  //   display: noen;
  // }
</style>
